import requests
x = 0


def get():
    url = 'https://uandme-uat-saletool-admin.jsunet.cn/backend/saletool/admin/api/auth/login/captcha/send'
    params = {
        'mobile': 13023802967
    }

    resp = requests.get(url, params=params)
    status_code = resp.status_code
    print('响应状态码：{}'.format(status_code))

    json = resp.json()
    print('响应内容：{}'.format(json))


def post():
    url = 'https://uandme-uat-saletool-admin.jsunet.cn/backend/saletool/admin/api/auth/login/captcha/check'
    headers = {
        'Content-Type': 'application/json'
    }

    payload = {
        "captcha": "11111",
        "mobile": "13023802967"
    }
    resp = requests.post(url=url, json=payload)
    status_code = resp.status_code
    print('登录响应状态码：{}'.format(status_code))

    json = resp.json()['data']
    print('响应内容：{}'.format(json))
    global x
    x = json
    print("获取的token值:{}".format(x))


def Activity(token):
    url = 'https://uandme-uat-saletool-admin.jsunet.cn/backend/saletool/admin/api/activity/detail/20'
    header = {
        'Authorization': token,
        'Content-Type': 'application/json'
    }
    resp = requests.get(url, json=header)
    status_code = resp.status_code
    print('响应状态码：{}'.format(status_code))

    json = resp.json()
    print('响应内容：{}'.format(json))


if __name__ == '__main__':
    get()
    post()
    Activity(x)
